using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using DevExpress.XtraReports.UI;
using NetROS.Tiers.Entities;
using System.IO;
using System.Windows.Forms;

namespace NetRosApp.Klijenti.Reports
{
    public partial class PrijemniListValutiStorno : DevExpress.XtraReports.UI.XtraReport, IParametriIzvjestaja
    {

        public PrijemniListValutiStorno()
        {
            InitializeComponent();
        }
        public PrijemniListValutiStorno(Dokument dokument)
        {
            InitializeComponent();
            bindingSource1.DataSource = dokument;

            ////System.Drawing.Imaging.Metafile tmp = new System.Drawing.Imaging.Metafile(@"H:\NetROS\NetRosApp\Slike\Reporti\zaglavlje.wmf");
            System.Drawing.Imaging.Metafile tmp = new System.Drawing.Imaging.Metafile(Application.StartupPath + "\\zaglavlje.wmf");
            int visina = tmp.Size.Height;
            int duzina = tmp.Size.Width;
            if (visina != 0)
            {
                xrPictureBox1.Height = (int)(((decimal)tmp.Height / (decimal)tmp.Width) * (decimal)650);
            }


            xrPictureBox1.Image = tmp;


        }



        #region IParametriIzvjestaja Members

        public void SetParametri()
        {
            Dokument _tmp = bindingSource1.DataSource as Dokument;

            if (_tmp != null)
            {
                if (_tmp.DokumentDodatakCollection.Count != 0)
                {
                    GroupHeader2.Visible = true;
                    Detail3.Visible = true;
                    GroupFooter2.Visible = true;
                }
            }
            //  throw new Exception("The method or operation is not implemented.");
        }

        #endregion


        private void xrLabel10_SummaryCalculated(object sender, TextFormatEventArgs e)
        {
            //

        }

        private void xrNC_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {

            if ((bindingSource1.DataSource as Dokument).DokumentStavkaCollection == null) return;
            if ((bindingSource1.DataSource as Dokument).DokumentStavkaCollection.Count == 0) return;
            float? tmp = (bindingSource1.DataSource as Dokument).DokumentStavkaCollection[0].ZTAutomatski;
            xrNC.Text = String.Format(" = {0:n4} % na NC", tmp);

        }
        int i = 0;
        private void xrLabel1_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            if (i == 1)
            {
                xrLabel1.Visible = false;
            }
            i = 1;
        }

        private void xrLabel37_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            // XRSummary tmp = xrLabel10.Summary;
            //XRSummary _nc = xrLabel37.Summary;

            ////nabvr = (customSum / nabvr) * 100
            //xrNC.Text = String.Format(" = {0:n4} % na NC", (Decimal.Parse(xrLabel10.Text.ToString()) / Decimal.Parse(_nc.GetResult().ToString())) * 100);

        }
    }
}
